package pers.qianyu.month_202012.date_20201206;

import org.junit.*;

import java.util.*;

/**
 * 650. 只有两个键的键盘
 * https://leetcode-cn.com/problems/2-keys-keyboard/
 *
 * @author mizzle rain
 * @date 2020-12-06 17:31
 */
public class MinSteps {
    public int minSteps(int n) {
        int res = 0, d = 2;
        while (n != 1) {
            while (n % d == 0) {
                res += d;
                n /= d;
            }
            d++;
        }
        return res;
    }

    /**
     * 测试素数分解
     */
    public void solve(int n) {
        ArrayList<Integer> list = new ArrayList<>();
        int d = 2;
        while (n != 1) {
            while (n % d == 0) {
                list.add(d);
                n /= d;
            }
            d++;
        }
        System.out.println(list);
    }

    @Test
    public void test1() {
        new MinSteps().solve(86);
    }
}
